﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using MusicHouse.Models.Prototipo;

namespace MusicHouse.Controllers
{
    public class PrototipoController : Controller
    {
        //
        // GET: /Prototipo/

        #region Inicio

        public ActionResult Index()
        {
            return View();
        }

        #endregion

        #region QuemSomos

        public ActionResult QuemSomos()
        {
            return View();
        }

        #endregion

        #region Partituras

        public ActionResult Partituras()
        {
            return View();
        }

        #endregion

        #region ContratarServico

        public ActionResult ContratarServico()
        {
            if (Session["usuario"] == null) return RedirectToAction("Login");
            if ((string) Session["usuario"] != "logado") return RedirectToAction("Login");

            List<TipoServico> lista = Models.Prototipo.TipoServico.RecuperarLista();
            ViewBag.TipoServico = new SelectList(lista, "Id", "Descricao"); 
            return View();
        }

        [HttpPost]
        public ActionResult ContratarServico(ContratarServico contratarServico)
        {

            return RedirectToAction("ListaCesta");
            
        }

        #endregion

        #region Login

        public ActionResult Login()
        {
            return View();
        }

        [HttpPost]
        public ActionResult Login(Login login)
        {
            Session["usuario"] = "logado";
            return RedirectToAction("ContratarServico");
            //return View();
        }

        #endregion

        #region Registrar

        public ActionResult Registrar()
        {
            List<Uf> lista = Uf.RecuperarLista();

            ViewBag.Sigla = new SelectList(lista, "Sigla", "Nome");
            return View();
        }

        [HttpPost]
        public ActionResult Registrar (Registrar registrar)
        {
            List<Uf> lista = Uf.RecuperarLista();

            ViewBag.Sigla = new SelectList(lista, "Sigla", "Nome");
            
            return View(registrar);
        }

        #endregion

        #region ListaCesta

        public ActionResult ListaCesta()
        {
            List<ListaCesta> lista = Models.Prototipo.ListaCesta.RetornarLista();
            ViewBag.TotalValor = lista.Sum(l => l.Valor);
            return View(lista);
        }

        #endregion


        #region ListaPedidos

        public ActionResult ListaPedidos()
        {
            return View();
        }

        #endregion



    }
}
